#!/usr/bin/python
# -*- coding: utf-8 -*-
# @Time    : 2021/7/4 18:08
# @Author  : Aaron
# @File    : contact_page
# @Software: PyCharm
from selenium.webdriver.support.wait import WebDriverWait
from calculator_pytest.po.add_member_page import AddMemberPage
from calculator_pytest.po.base_page import BasePage


class ContactPage(BasePage):

    # 点击添加成员
    def add_member(self):
        self.driver.find_elements_by_link_text("添加成员")[0].click()

        return AddMemberPage(self.driver)

    def get_member_name(self):
        WebDriverWait(
            self.driver, 10).until(
            lambda driver: driver.find_element_by_link_text("通讯录"))
        result = self.driver.find_elements_by_css_selector(
            ".member_colRight_memberTable_td:nth-child(2)")

        usernames = [ele.get_attribute("title")
                     for ele in result if ele.get_attribute("title")]
        return usernames
